<script setup lang="ts">


import wx from "weixin-js-sdk";
import axios from "axios";
import useAxiosApi from "/@/utils/useAxiosApi";

onMounted(() => {

  //getUrlParam方法就是使用正则截取地址栏里的code
  function getUrlParam(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]);
    return null;
  }

  //获取用户的openid
  function getOpenId(code) {
    useAxiosApi("/stCheckLogin", {
      method: "post",
      params: {
        code: code,
      },
    }).then(function (result) {
      console.log(result)

    })
    /* let result = axios({
       method: 'post',
       url: "/api/getOpenid",
       data: {code: code},
       header: {
         'Content-Type': 'application/x-www-form-urlencoded'
       }
     }).then(function (result) {
       var wxResult = result.data.data;
       var openid = wxResult.openid;
     }).catch(error => {
       //待完善弹窗
     });*/
  }

  var redirect = encodeURIComponent(window.location.href); //重定向回来的地址
  var wx_code = getUrlParam("code"); // 截取url中的code
  console.log("wx_code", wx_code)

})
</script>

<template>

</template>

<style scoped lang="less">

</style>
